from google.appengine.ext import db

service_map = {'Generic': 0, 'Dws': 1, 'Portal': 2, 'Test': 3, 'Nexus': 4}

class Entry(db.Model):
    service_id = db.IntegerProperty(required=True) # different id for each purpose 
    name = db.StringProperty(required=True, multiline=True)
    date = db.DateTimeProperty(auto_now_add=True)

def getAll(service_name):
    return db.GqlQuery("SELECT * FROM Entry "
                            "WHERE service_id = %d"
                            "ORDER BY date DESC" % service_map[service_name])

def put(service_name, content):
    e = Entry(service_id=service_map[service_name], name=content)
    e.put()
